package com.superzqb.asus.superzqbFragment.superzqbSave.Adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.superzqb.asus.superzqb.R;

import java.util.ArrayList;
import java.util.Map;

/**
 * Created by asus on 2017/3/13.
 */

public class WelfareAdapter extends BaseAdapter {
    Context context;//上下文
    ArrayList<Map<String,Object>> list;//动态数组
    LayoutInflater inflater;//动态加载布局
    //构造方法传递参数
    public WelfareAdapter(Context context,ArrayList<Map<String,Object>>  list) {
        this.context=context;
        this.list=list;
    }
    @Override
    public int getCount() {
        return list==null?0:list.size();
    }

    @Override
    public Object getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public boolean isEnabled(int position) {
        return false;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        if(convertView==null){
            convertView = LayoutInflater.from(context).inflate(R.layout.welfare_item,parent,false);
            convertView.setTag(new WelfareAdapter.ViewHolder(convertView));
        }
        WelfareAdapter.ViewHolder holder=(WelfareAdapter.ViewHolder)convertView.getTag();
        Map<String,Object> map=list.get(position);
        holder.info1.setText(map.get("info1").toString());
        holder.info2.setText(map.get("info2").toString());
        isEnabled(position);
        return convertView;
    }
    class ViewHolder{
        private TextView info1,info2;
        private LinearLayout all;
        public ViewHolder(View view){
            info1=(TextView)view.findViewById(R.id.info1);
            info2=(TextView)view.findViewById(R.id.info2);
            all=(LinearLayout)view.findViewById(R.id.all);
        }

    }
}
